<?php

namespace App\Http\Controllers\Admin;

use App\Models\Node;
use Illuminate\Http\Request;

class NodeController extends BaseController
{
    /**
     * 节点列表
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        //获取所有节点
        $data = (new Node())->getAllList();

        //$data = Node::all();
        $kw = '搜索站位';

        return view('admin.node.index',compact('data','kw'));

    }

    /**
     * 添加界面显示
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        //获取所有顶部
        $data = Node::where('pid',0)->get();

        return view('admin.node.create',compact('data'));
    }

    /**
     * 添加处理
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    {
        //表单验证
        //try() catch()
        //入库
        Node::create($request->except(['_token','/admin/node']));
        return ['status'=>0,'msg'=>'添加权限成功'];

    }

    /**
     * 显示单条详情
     *
     * @param  \App\Models\Node  $node
     * @return \Illuminate\Http\Response
     */
    public function show(Node $node)
    {
        //
    }

    /**
     * 显示编辑界面
     *
     * @param  \App\Models\Node  $node
     * @return \Illuminate\Http\Response
     */
    public function edit(Node $node)
    {
        //
    }

    /**
     * 处理编辑
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \App\Models\Node  $node
     * @return \Illuminate\Http\Response
     */
    public function update(Request $request, Node $node)
    {
        //
    }

    /**
     * 删除处理
     *
     * @param  \App\Models\Node  $node
     * @return \Illuminate\Http\Response
     */
    public function destroy(Node $node)
    {
        //
    }
}
